package mini.ideashare.cms.controller;

import com.taobao.api.ApiException;
import com.taobao.api.TaobaoClient;
import com.taobao.api.request.TbkCouponGetRequest;
import com.taobao.api.response.TbkCouponGetResponse;
import mini.ideashare.cms.common.TBClientFactory;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
public class CouponController extends AbstractBaseController{

    @GetMapping("/coupon/get")
    @ResponseBody
    public String getCoupon(TbkCouponGetRequest req){
        TaobaoClient client = TBClientFactory.getClient();
        TbkCouponGetResponse rsp = null;
        try {
            rsp = client.execute(req);
        } catch (ApiException e) {
            e.printStackTrace();
        }
        return rsp.getBody();
    }
}
